﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace WebUI.Pages
{
    public partial class mgrStages : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get credentials
            UserController usrController = new UserController();
            int secUsuario = usrController.GetUserID(User.Identity.Name);
            int secTeam = usrController.GetUserTeamID(secUsuario);

            if (secTeam != 9)
            {
                Response.Redirect("../Pages/403.aspx");
            } 
            
            
            EstagioVendaController evController = new EstagioVendaController();
            if (!this.IsPostBack)
            {
                rpEstagiosVenda.DataSource = evController.GetEstagios();
                rpEstagiosVenda.DataBind();
            }
        }

        protected void cmdNovo_Click(object sender, EventArgs e)
        {
            EstagioVendaController evController = new EstagioVendaController();
            evController.NewEstagioVenda(txtNome.Text);
            Response.Redirect("../Pages/mgrStages.aspx");
        }

        protected void rpEstagiosVenda_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Response.Redirect("../Pages/editStage.aspx?id=" + e.CommandArgument.ToString());
        }
    }
}